#include "cseditorundocommands.h"
#include "collisionshapesdocument.h"

CSEditorAbstractCmd::CSEditorAbstractCmd(CollisionShapesDocument &csDoc)
    : m_csDoc(csDoc)
{
}


CSEditorCreateCollisionShapeCmd::CSEditorCreateCollisionShapeCmd(CollisionShapesDocument &csDoc, QPointer<CollisionShape> shape, bool bAdd)
    : CSEditorAbstractCmd(csDoc)
    , m_shape(shape)
    , m_bAdd(bAdd)
{
}

void CSEditorCreateCollisionShapeCmd::undo()
{
    if(m_bAdd)
    {
        m_csDoc.deleteShape(m_shape);
    }
    else
    {
        m_csDoc.addShape(m_shape);
    }
}

void CSEditorCreateCollisionShapeCmd::redo()
{
    if(m_bAdd)
    {
        m_csDoc.addShape(m_shape);
    }
    else
    {
        m_csDoc.deleteShape(m_shape);
    }
}
